package com.jmyd.coupon.server.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 优惠券类型
 *
 * @author samphin
 * @since 2021-7-14 13:40:20
 */
public enum SceneCouponExclusiveStatusEnum {
    /**
     * 优惠券类型:1：折扣券，2：满减券 3：免单券 4：立减券 5：随机券
     */
    TRUE(true, "互斥"),
    FALSE(false, "不互斥");

    @Getter
    private Boolean code;
    @Getter
    private String desc;

    SceneCouponExclusiveStatusEnum(boolean code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getByCode(boolean code) {
        Optional<SceneCouponExclusiveStatusEnum> optional = Arrays.stream(SceneCouponExclusiveStatusEnum.values()).filter(en -> en.getCode() == code).findFirst();
        return optional.map(SceneCouponExclusiveStatusEnum::getDesc).orElse(null);
    }
}
